package cn.icatw.yygh.hosp.controller;

import cn.icatw.yygh.common.result.Result;
import cn.icatw.yygh.hosp.service.HospitalService;
import cn.icatw.yygh.hosp.service.ScheduleService;
import cn.icatw.yygh.model.hosp.Hospital;
import cn.icatw.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 医院管理controller
 *
 * @author 76218
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院列表（条件分页查询）
     *
     * @param page            当前页
     * @param limit           当前页总记录数
     * @param hospitalQueryVo 封装条件
     * @return page
     */
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    /**
     * 更新医院上线状态
     *
     * @param id     医院id
     * @param status 医院上线状态
     * @return 统一结果集
     */
    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id, @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    /**
     * 获取医院详情信息
     *
     * @param id 医院id
     * @return 医院详情信息
     */
    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String, Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }

}
